def main():
    y_or_n = input('是否退出程序(y/n)？')
    while y_or_n !='y':
        try:
            gender = input('性别:') #性别
            weight = float(input('体重(kg):'))#体重
            height = float(input('身高(cm):'))#身高
            age = int(input('年龄：'))#年龄

            if gender == '男':
               bmr = (13.7 * weight) +(5.0*weight) - (6.8 * age) + 66 #BMR(男) = (13.7×体重(kg)) + (5.0×身高(cm)) - (6.8×年龄) + 66

            elif gender == '女':
               bmr = (9.6 * weight) + (1.8 * weight) - (4.7 * age) + 655 #BMR(女) = (9.6×体重(kg)) + (1.8×身高(公分)) - (4.7×年龄) + 655
            else :
               bmr = -1
            if bmr !=-1:
                print('基础代谢率:',bmr)
            else :
             print('性别输入错误')
             print()
             y_or_n = input('是否退出程序(y/n)？')
        except ValueError:
            print("身高，体重和年龄处请输入阿拉伯数字！")
            print()
        except NameError:
            print("身高，体重和年龄处请输入阿拉伯数字！")
            print()
        except TypeError:
            print("身高，体重和年龄处请输入阿拉伯数字！")
            print()
main()


